<!--#layout("/common/layout.html",{"jsBase":"/js/cms/xxdBest/"}){ -->

<!--<layui:searchForm formId="searchForm"  condition="${search}">-->
<!--</layui:searchForm>-->

<div class="layui-btn-group">
    <button id="updatedb" onclick="butClick()" class="layui-btn">手动更新数据</button>
    <layui:accessButton function="cms.xxdItem.details"  action="details">详情</layui:accessButton>e
</div>

<table id="xxdActivitieTable" lay-filter="xxdActivitieTable"></table>
<!--#} -->
<script>

layui.use(['index','layer'], function(){
    var index = layui.index
    index.init();
});

function butClick(){
    var url = Common.ctxPath + '/cms/xxdBest/update.do';
    $.ajax({
        url: url,
        type:'post',
        dataType: "json",
        success:function (result) {
            layui.use(['layer'], function(){
                if(result == '200'){
                    var text = "更新数据成功!  最佳销售默认为排名前4件商品"
                    layer.open({
                        offset: 1 //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                        ,content: '<div style="padding: 20px 100px;">'+ text +'</div>'
                        ,btn: '关闭'
                        ,btnAlign: 'c' //按钮居中
                        ,shade: 0 //不显示遮罩
                        ,yes: function(){
                            layer.closeAll();
                            location.reload();
                        }
                    });
                }else if(result == '500'){
                    console.log("服务器错误！")
                }
            });

        }
    });
}


</script>
